package com.lianzhihui.romeex.mvp.model;

import android.content.Context;

import com.lianzhihui.romeex.bean.WalletMainBean;
import com.lianzhihui.romeex.net.APIConstant;
import com.lianzhihui.romeex.net.HttpManager;
import com.lianzhihui.romeex.net.HttpManagerCallback;
import com.lianzhihui.romeex.net.ResultData;
import com.lianzhihui.romeex.utils.GsonUtil;
import com.lianzhihui.romeex.utils.LogUtil;
import com.zhouyou.http.exception.ApiException;
import com.zhouyou.http.model.HttpParams;

/**
 * Description:
 * Author: RAMON
 * CreateDate: 2020/11/10 10:14 AM
 * UpdateUser:
 * UpdateDate:
 * UpdateRemark:
 * Version:
 */
public class SyncUserModel {

    Context context;
    SyncUserInterface callback;

    public SyncUserModel(Context context, SyncUserInterface callback) {
        this.context = context;
        this.callback = callback;
    }

    public void syncUser(String address) {

        HttpParams params = new HttpParams();
        params.put("userAddress", address);
        new HttpManager(context, new HttpManagerCallback() {
            @Override
            public void onSuccess(ResultData o) {
                LogUtil.info("walletInfo:", o.getCode() + "");
                if (o.getCode() == 200) {
                    callback.onSync();
                } else {
                    callback.onSyncFail(o.getCode());
                }
            }

            @Override
            public void onError(ApiException e) {
                callback.onSyncFail(e.getMessage());
            }
        }).post(APIConstant.SYNC_USER, params);
    }

}
